package com.beauty.dressing.module.market.holder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseRecyclerViewHolder;
import com.beauty.dressing.common.bean.Ad;
import com.beauty.dressing.common.bean.BaseBean;
import com.beauty.dressing.common.bean.StringBase;
import com.beauty.dressing.common.view.NoScrollGridView;
import com.beauty.dressing.module.common.view.BannerLayout;
import com.beauty.dressing.rxandroid.api.ApiManager;
import com.facebook.drawee.view.SimpleDraweeView;
import com.framework.common.base.IBaseAdapter;
import com.xiaolanba.commonlib.fresco.FrescoUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by aaa on 2018/5/17.
 */

public class DetailHeaderHolder extends BaseRecyclerViewHolder<BaseBean> {
    private BannerLayout mBanner;
    private NoScrollGridView mGridview;
    public DetailHeaderHolder(Context context, LayoutInflater inflater, ViewGroup viewGroup) {
        super(R.layout.detail_header_top, context, inflater, viewGroup);
    }

    @Override
    public void findView() {
        mBanner = itemView.findViewById(R.id.banner_layout);
        mBanner.adjustHeight(0.5f);
        mGridview = itemView.findViewById(R.id.gridview);
    }

    @Override
    public void bindData(BaseBean bean, int position) {
        List<Ad> adList = new ArrayList<>();
        adList.add(new Ad("http://images.9zhitx.com/a97d8b8b-d703-46c3-9700-b966c8fa7dcb.jpg",null));
        adList.add(new Ad("http://images.9zhitx.com/ac870ecd-26f4-4670-9364-8a542b4e322a.jpg",null));
        adList.add(new Ad("https://tvax2.sinaimg.cn/crop.0.0.664.664.180/006zWmitly8fgxj1jcsevj30ig0igt9h.jpg",null));
        mBanner.setBannerPagerAdapter(adList,true);
        HeadDetailAdapter adapter = new HeadDetailAdapter(mContext);
        List<BaseBean> list = new ArrayList<>();
        for (int i=0;i<6;i++){
            list.add(new BaseBean());
        }
        adapter.setList(list);
        mGridview.setAdapter(adapter);
    }

    private class HeadDetailAdapter extends IBaseAdapter<BaseBean>{

        public HeadDetailAdapter(Context context) {
            super(context);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            DetailImgHolder holder = new DetailImgHolder(mContext, mInflater, parent);
            convertView = holder.itemView;
            holder.bindData(new BaseBean(),position);
            return convertView;
        }
    }
}
